<?php
/**
 * Created by JetBrains PhpStorm.
 * User: Evan
 * Date: 12-10-12
 * Time: 上午7:39
 * To change this template use File | Settings | File Templates.
 */
abstract class Jwawa_BaseModel
{

    function __construct(&$prop_array = null)
    {
        if($prop_array == null) return;

        foreach($prop_array as $key => $val){
            $low_key = strtolower($key);
            $this->$low_key = $val;
        }
    }

    public static function getDb(){
        return Zend_Db_Table::getDefaultAdapter();
    }

    public static function getDefaultStatementClass(){
        return self::getDb()->getStatementClass();
    }

    public static  function getLog(){
        return Zend_Registry::get('log');
    }

    public static function createDefaultStmt($db, $sql){
        $stmtClass = self::getDefaultStatementClass();
        return new $stmtClass($db, $sql);
    }
}
